// 联系社交媒体
export const toSocialMedia = (channel: string) => {
  let url
  switch (channel) {
    case 'facebook':
      url = 'https://www.facebook.com/sdao.win'
      break
    case 'twitter':
      url = 'https://twitter.com/sdaowin'
      break
    case 'whatsapp':
      url = 'https://chat.whatsapp.com/EB83oIJYbQhIKz90miHiJk'
      break
    case 'telegram':
      url = 'https://t.me/sdclen'
      break
    case 'reddit':
      url = 'https://www.reddit.com/r/sdaowin/'
      break
    case 'vk':
      url = ''
      break
    case 'linkedin':
      url = ''
      break
    case 'discord':
      url = 'https://discord.gg/v7KsCPQJWs'
      break
    case 'line':
      url = 'https://line.me/ti/g/jiAjSJa02Q'
      break
    case 'zalo':
      url = 'https://zalo.me/g/emsrbi424'
      break
    case 'skype':
      url = 'https://join.skype.com/WaPvg5F1rwXP'
      break
    case 'pinterest':
      url = 'https://www.pinterest.com/sdaowin'
      break
    case 'flipboard':
      url =
        'https://flipboard.com/@sdaowin'
      break
    case 'tumblr':
      url = 'https://sdaowin.tumblr.com/'
      break
    case 'snapchat':
      url = 'https://www.snapchat.com/add/sdaowin'
      break
    case 'viber':
      url =
        'https://invite.viber.com/?g2=AQAMWfCRns74rk9j%2Fn0Vj%2Fnj1pSAgz176OEn%2BXV6qM5rGflIDQfDS7AXiruzzQ8X'
      break
    case 'instagram':
      url = 'https://www.instagram.com/sdao.win'
      break
    case 'youtube':
      url = 'https://www.youtube.com/channel/UCkSK-wjtvWfD4qWjdhs5N2Q'
      break
    case 'tiktok':
      url = 'https://www.tiktok.com/@sdaowin'
      break
    case 'medium':
      url = 'https://medium.com/@sdaowin'
      break
    case 'github':
      url = 'https://github.com/sdaowin'
      break
    default:
      url = 'https://www.youtube.com/channel/UCfIJiyBVcoYhII9DukSJpEQ/featured'
      return
  }
  window.open(url, 'newwindow', 'left=410,height=610, width=860, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
}

export const resolveRole = (role: number | undefined): string => {
  if (role === 1) {
    // 鼠鲨
    return 'Porbeagle'
  } else if (role === 2) {
    // 大青鲨
    return 'Great blue shark'
  } else if (role === 3) {
    // 锤头鲨
    return 'Hammerhead shark'
  } else if (role === 4) {
    // 虎鲨
    return 'Tiger shark'
  } else if (role === 5) {
    // 睡鲨
    return 'Sleeping shark'
  } else if (role === 6) {
    // 大白鲨
    return 'Great white shark'
  } else if (role === 7) {
    // 姥鲨
    return 'Basking shark'
  } else if (role === 8) {
    // 鲸鲨
    return 'Whale shark'
  } else if (role === 9) {
    // 巨齿鲨
    return 'Megalodon'
  }
  return ''
}

export const languageOptions = [
  {title: 'English', language: 2},
  {title: 'Indonesian', language: 15},
  {title: 'Japanese', language: 3},
  {title: 'Korean', language: 6},
  {title: 'Vietnamese', language: 7},
  {title: 'Chinese_TW', language: 1},
]

export const resolveLanguage = (lang: number | undefined) => {
  console.log('lang:', lang)
  if (lang === undefined) {
    return undefined
  }
  return languageOptions.find((item: any) => (item.title === lang || item.language === lang || item.title.indexOf(lang) != -1))?.language
}

export const resolveLanguageName = (lang: number|undefined) => {
  console.log('lang:', lang)
  const result = languageOptions.find((item: any) => (item.language === lang))
  if (result) {
    return result.title
  } else {
    return lang
  }
}

export const openUrl = (url: string) => {
  window.open(url, '__blank')
}
